<?php #20070705 http://www.framework.altervista.org/FrameWork/applications/_admin/application.inc
define('APPSCHEDARIO','1.20');
/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/


// schedario application applicazione per ospitare piu applicazioni in una pagina selezionabili tramite linguette

$appname=$_GET['appname'];
$subapp=$_GET['subapp'];






if($folderlevel=="")$folderlevel=0;
//echo "folderlevel=$folderlevel : path=$path : appname=$appname  : subapp=$subapp <br/>";//DEBUG

if ($folderlevel==0){
    $tmp=explode("/",$appname);
    $appname=$tmp[0];
    $container="";
    if ($tmp[1]!="")$subapp=$tmp[1];
}
else{
    if (substr_count($appname,"/")==0){
	$appname.="/".$subapp;
	$subapp="";
    }
    else{
    $tmp=explode("/",$appname);
    $appname=$tmp[0]."/".$tmp[1];
    if ($tmp[2]!="")$subapp=$tmp[2];
    }
    unset( $appnames);
}


//carica la lingua se esiste
$lang=lang();
switch($lang){
    case "en":
	define("_COMBOMENU","Other .....");
	break;
    default:
	define("_COMBOMENU","Altro .....");
	break;
}



//aggiorna il path
if (!file_exists("datas/$path/$apptitle"))mkdir("datas/$path/$apptitle",0755);

?>

<?php structure_openBlock("table appl",apptitle($appname),""); ?>

<p>
<?php
$i=0;
$fd=opendir("$path/$appname");
while (false !== ($nf= readdir($fd))){
    if ($nf[0]!='.' && $nf[0]!='_' && $nf!="application.inc")
	if (is_dir("$path/$appname/$nf") || substr($nf,-4)==".inc")
	    $appnames[$i++]="$nf";
}
closedir($fd);


echo "<p class='linguetta-body'>\n";
echo "<!-- menu -->\n";

if ($i>0){
    sort($appnames);
    if ($subapp=="")$subapp=$appnames[0];
    $a=0;
    foreach($appnames as $app_name){
	if ($a==get_config("applications/".apptitle(appname())."/numero_schede","4")){
	    echo "<select class='linguetta' class='select' onChange=\"location=''+this.value;\" >\n";
     	    echo "<option value='index.php?appname=$appname&subapp='>"._COMBOMENU."</option>\n";
	}
	if ($a>=get_config("applications/".apptitle(appname())."/numero_schede","4")){
	    if($subapp!="$app_name")
		echo "<option value='index.php?appname=$appname&subapp=$app_name'>".apptitle($app_name)."</option>";
	    else
		echo "<option selected value='index.php?appname=$appname&subapp=$app_name'>".apptitle($app_name)."</option>";
	}
	else{
	    $apptitle=apptitle($app_name);
	    $theme=theme();
	    if($subapp!="$app_name"){
		echo"<span class='linguettaleft'></span><span class='linguetta'>";
		if (get_config("menugraphics/b-admin_graphic_menu","")=="on"){
		    if (file_exists("applications/$appname/$app_name/images/$apptitle.png")) {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='applications/$appname/$app_name/images/$apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		    elseif(file_exists("applications/$appname/_images/$apptitle.png")) {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='applications/$appname/_images/$apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		    else {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='themes/$theme/images/default_apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		}
		else{
		    echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle<IMG src='themes/$theme/images/bullet2.gif' border=0 title='$apptitle' ></a>";
		}
		echo"</span><span class='linguettaright'></span>\n";

	    }
	    else{
		echo"<span class='linguettaleft'></span><span class='linguetta sel'>";
		if (get_config("menugraphics/b-admin_graphic_menu","")=="on"){
		    if (file_exists("applications/$appname/$app_name/images/$apptitle.png")) {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='applications/$appname/$app_name/images/$apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		    elseif(file_exists("applications/$appname/_images/$apptitle.png")) {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='applications/$appname/_images/$apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		    else {
			echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle <IMG src='themes/$theme/images/default_apptitle.png' border=0 width='40' height='40' Hspace='0' Vspace='0' title='$apptitle' ></a>";
		    }
		}
		else{
		    echo "<a accesskey=\"$accesskey\" href='index.php?appname=$appname&subapp=$app_name' >$apptitle<IMG src='themes/$theme/images/bullet2.gif' border=0 title='$apptitle' ></a>";
		}
		echo"</span><span class='linguettaright'></span>\n";
	    }
	}
	$a++;
    }
    if ($a>=4){
	echo "</select>\n";
    }
    echo "<hr />\n";
    echo "</p>\n";

    $container=$appname; //per retro compatibilita'
    $appname="$appname/$subapp";
    $apptitle=apptitle($appname);


    if (is_dir("$path/$appname")){
	$folderlevel++;
	include "$path/$appname/application.inc";
    }
    else{
	$folderlevel++;
	include "$path/$appname";
    }

}
?>
</p>
<?php structure_closeBlock(); ?>
